package me.luger.core.mvc.filter.pagecache.entity;

import net.sf.ehcache.constructs.web.AlreadyGzippedException;
import net.sf.ehcache.constructs.web.Header;
import net.sf.ehcache.constructs.web.PageInfo;

import java.io.Serializable;
import java.util.Collection;

/**
 * WebPageInfo
 *
 * @author luger
 * @date 2016/8/18 0018
 */
public class WebPageInfo extends PageInfo{
    private static final long serialVersionUID = -5509940598061623260L;

    /**
     * 设置但未命中缓存
     */
    public static final int CACHE_UNUSE = 0;
    /**
     * 命中缓存
     */
    public static final int CACHE_USE = 1;

    /**
     * 未设置缓存
     */
    public static final int CACHE_UNSET = 2;

    /**
     * 缓存设置异常
     */
    public static final int CACHE_ERROR = 3;


    /**
     * 缓存主动清理
     */
    public static final int CACHE_KILL = 4;

    /**
     * 使用缓存状态未知
     */
    public static final int CACHE_UNKNOWUSE = 9;

    /**
     * 是否从缓存读取数据
     */
    private int cache = CACHE_UNKNOWUSE;

    public WebPageInfo(int statusCode, String contentType, Collection cookies,
                       byte[] body, boolean storeGzipped, long timeToLiveSeconds,
                       Collection<Header<? extends Serializable>> headers)
            throws AlreadyGzippedException {
        super(statusCode, contentType, cookies, body, storeGzipped,
                timeToLiveSeconds, headers);
    }

    public int getCache() {
        return cache;
    }

    public void setCache(int cache) {
        this.cache = cache;
    }
}
